<cc:page type="normal" style="standard" showSidebar="false" showHeader="false" />
<cc>
    String pp = request.getParameter("pp") == null ? "" : request.getParameter("pp") + "";//品牌
    String ssmd = request.getParameter("ssmd") == null ? "" : request.getParameter("ssmd") + "";//门店
    String start_time = request.getParameter("start_time") == null ? "" : request.getParameter("start_time") + "";//开始时间
    String end_time=request.getParameter("end_time") == null ? "" : request.getParameter("end_time") + "";//结束时间
    Date date=new Date();
    SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM-dd");
    String today= sf.format(date);
    if("".equals(start_time)){
    start_time=today;
    }
    if("".equals(end_time)){
    end_time=today;
    }
    String is_back=request.getParameter("is_back") == null ? "" : request.getParameter("is_back") + "";//是否返厂
    CCService ccs = new CCService(userInfo);
    String msg = "{\"code\",\"1\"}";
    String sql="select a.id,b.gmsl, c.name as jdry,a.gkdh,a.xkhxm,a.cjje,b.sbxh,b.hgh,d.name as ppname,e.name as mdname,b.chbm,b.cjje as xsjg,DATE_FORMAT(a.ddrq,'%Y-%m-%d') as ddrq,a.name as ddbh,a.id as ddid,b.sbdpj as sbdpj,a.kpje as kpje "+
    "from ddmx b  left join ddxx a  on a.id=b.ddxx "+
    "left join pp d on b.gmpp=d.id "+
    "left join ygpzb c on a.xsjdry=c.id "+
    "left join mdpzb e on a.ssmd=e.id "+
    "where b.is_deleted='0' and a.is_deleted='0' and a.kdzt='已完成' ";
    //门店不等于空
    if(!"".equals(ssmd)){
    sql+="and a.ssmd='"+ssmd+"' ";
    }
    //品牌不等于空
    if(!"".equals(pp)){
    sql+="and b.gmpp='"+pp+"' ";
    }
    //开始时间
    if(!"".equals(start_time)){
    sql+="and a.ddrq>='"+start_time+"' ";
    }
    //结束时间
    if(!"".equals(end_time)){
    sql+="and a.ddrq<='"+end_time+"' ";
    }
    //是否返厂
    if("是".equals(is_back)){
    sql+="and a.sffc='是' ";
    }
    List<CCObject> spxx_info = ccs.cqlQuery("", sql);
    net.sf.json.JSONObject result = new net.sf.json.JSONObject();
    net.sf.json.JSONArray data = new net.sf.json.JSONArray();

    for (CCObject cc :
    spxx_info
    ) {
    net.sf.json.JSONObject json = new net.sf.json.JSONObject();

    String id=cc.get("id")+"";
    String num="";
    List<CCObject> num_list = ccs.cqlQuery("", "select count(*) as num from ddmx where ddxx='"+id+"'");
        if(num_list.size()>0){
        num=num_list.get(0).get("num")==null?"":num_list.get(0).get("num")+"";
        }
        String gmsl=cc.get("gmsl")+"";//购买数量
        String xsjg=cc.get("xsjg")+"";//销售价格
        String xkhxm=cc.get("xkhxm")+"";//顾客姓名
        String hgh=cc.get("hgh")+"";//后盖号
        String ddbh=cc.get("ddbh")+"";//订单编号
        String sbxh=cc.get("sbxh")+"";//手表型号
        String cjje=cc.get("cjje")+"";//成交金额
        String jdry=cc.get("jdry")+"";//接待人员
        String ddrq=cc.get("ddrq")+"";//订单日期
        String ddid=cc.get("ddid")+"";//订单id
        String mdname=cc.get("mdname")+"";//门店名称
        String ppname=cc.get("ppname")+"";//品牌名称
        String gkdh=cc.get("gkdh")+"";//顾客电话
        String chbm=cc.get("chbm")+"";//存货编码
        String sbdpj=cc.get("sbdpj")+"";//手表吊牌价
        String kpje=cc.get("kpje")+"";//开票金额
        json.put("id",id);
        json.put("xsjg",xsjg);
        json.put("xkhxm",xkhxm);
        json.put("hgh",hgh);
        json.put("ddbh",ddbh);
        json.put("sbxh",sbxh);
        json.put("cjje",cjje);
        json.put("jdry",jdry);
        json.put("ddrq",ddrq);
        json.put("ddid",ddid);
        json.put("mdname",mdname);
        json.put("ppname",ppname);
        json.put("gkdh",gkdh);
        json.put("chbm",chbm);
        json.put("sbdpj",sbdpj);
        json.put("gmsl",gmsl);
        json.put("kpje",kpje);
        data.add(json);
        }
        result.put("total", data.size());
        result.put("rows", data);
        result.put("sql", sql);
        msg = result.toString();
        request.setAttribute("jsonmsg", msg);
</cc>
<cc:forward page="/platform/activity/task/getNodes.jsp">
    <cc:param name="jsonmsg" value="" />
</cc:forward>